home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / PPCExamples / FatMakefile
Encoding:
Makefile  |  1998-12-03  |  12.7 KB  |  322 lines  |  [TEXT/MPS ]

  1. #
  2. #   FatMakefile
  3. #
  4. #    Example MPW makefile for building 68K, PowerPC, and Fat versions of 
  5. #    applications.
  6. #
  7. #   Authors:            Richard Clark
  8. #                        Jordan Mattson
  9. #                        Eric Traut
  10. #
  11. #    © Copyright 1993, Apple Computer, Inc
  12. #   All rights reserved
  13. #
  14. #    History:
  15. #
  16. #    09/29/93, JM                — First public release
  17. #    10/21/93, JM                — Updated to work with the Macintosh on RISC SDK, Alpha Release
  18. #
  19. #
  20. #    Command Line Examples:
  21. #
  22. #        Make -f FatMakefile all
  23. #        Make -f FatMakefile MyApp.noopt.PPC
  24. #        Make -f FatMakefile MyApp.opt.PPC
  25. #        Make -f FatMakefile MyApp.noopt.68K
  26. #        Make -f FatMakefile MyApp.opt.68K
  27. #        Make -f FatMakefile MyApp.noopt.fat
  28. #        Make -f FatMakefile MyApp.opt.fat
  29. #
  30. #    Description:
  31. #
  32. #    This makefile builds non-optimized 680x0, optimized, 680x0, non-optimized PowerPC,
  33. #    optimized PowerPC, non-optimized fat binary, and optimized fat binary versions of
  34. #    an application.
  35. #
  36. #    This makefile assumes that folders and files associated with the project
  37. #    MyProject is included in a folder with the path {Boot}MyProjects:MyProject.
  38. #    Included in this folder are the following:
  39. #
  40. #        FatMakefile                    — This makefile adapted to your project
  41. #
  42. #        IncludesF                    — A folder containing your application’s include
  43. #                                    files.
  44. #
  45. #        SourcesF                    — A folder containing your application’s source files.
  46. #
  47. #        ResourcesF                    — A folder containing your application’s rez files.
  48. #
  49. #        PPCObjectsNoOptF            — A folder containing your application’s non-optimized
  50. #                                    PowerPC object files.
  51. #
  52. #        PPCObjectsOptF                — A folder containing your application’s optimized
  53. #                                    PowerPC object files.
  54. #
  55. #        68KObjectsNoOptF            — A folder containing your application’s non-optimized
  56. #                                    68K object files.
  57. #
  58. #        68KObjectsOptF                — A folder containing your application’s optimized
  59. #                                    68K object files.
  60. #
  61. #
  62. #    You need to search for and modify the following variable definitions:
  63. #
  64. #        AppName                — Change from "MyApp" to the actual name of your application.
  65. #
  66. #        Creator                — Change from 'XXXX' to the correct creator for your application
  67. #
  68. #        RootPath            — "MyProjects" and "MyProject" to the actual name of your projects
  69. #                            folder and the folder for this particular project.
  70. #
  71. #        AppRscs                — Change from "MyApp.r" to the actual name of the Rez file containing
  72. #                            your resources.
  73. #
  74. #        PPCAppRscs            — Change from "MyPPCApp.r" to the actual name of the Rez file containing
  75. #                            your PowerPC specific resources.
  76. #
  77. #        MergeCodeRscsNoOpt    — No need to change the variable definition, but you do need
  78. #                            to create a file with this name to create your non-optimized fat
  79. #                            binary.
  80. #
  81. #        MergeCodeRscsOpt    — No need to change the variable definition, but you do need to create
  82. #                            a file with this name to create your optimized fat binary.
  83. #
  84.  
  85. # Define the name of the application.
  86. AppName =                 MyApp
  87.  
  88. # Define the creator and type for our application.
  89. Creator =                'XXXX'
  90. Type =                    'APPL'
  91.  
  92. # Define the path to our root for this project.
  93. RootPath =            "{Boot}"MyProjects:MyProject:
  94.  
  95. # Define the names of the folders that contain the include, source, and resource files.
  96. IncludesF =            "{RootPath}"Includes:
  97. SourcesF =            "{RootPath}"Sources:
  98. ResourcesF =        "{RootPath}"Resources:
  99.  
  100. # Define the names of the folder that contain the PPC optimized and non-optimized object 
  101. # and the 68K optimized and non-optimized files.
  102. PPCObjectsNoOptF =    "{RootPath}"ObjectsNoOptPPC:
  103. PPCObjectsOptF =    "{RootPath}"ObjectsOptPPC:
  104. 68KObjectsNoOptF =    "{RootPath}"ObjectsNoOpt68K:
  105. 68KObjectsOptF =    "{RootPath}"ObjectsOpt68K:
  106.  
  107. # Symbolics are off when we are not doing a debug build, but on when we are doing a symbolic build.
  108. Symbolics =                on
  109.  
  110. # Setup the definitions for PPCC no optimizations and optimizations. For this program we are choosing
  111. # to optimize for speed. You can optimize for speed or size and choose you level of optimization.
  112. # Note that do to the cache architecture of the PowerPC, optimizing for size can sometimes lead
  113. # to a faster executable, and optimizing for speed can sometimes lead to a slower executable. The
  114. # only way to tell is by trying it out with your program.
  115. PPCNoOptimizations =    off
  116. PPCOptimizations =        speed
  117.  
  118. # Setup the definitions for the 68K no optimizations and optimziations.
  119. 68KNoOptimizations =    off
  120. 68KOptimizations =        on
  121.  
  122. # Define the various resource files.
  123. AppRscs =                MyApp.r
  124. PPCAppRscs =            MyPPCApp.r
  125. MergeCodeRscsNoOpt =    MergeCode.NoOpt.r
  126. MergeCodeRscsOpt =        MergeCode.Opt.r
  127.  
  128. # Define the libraries we must link with for the PowerPC. You may or may not need some of these
  129. # files, but we have defined them all.
  130. StandardLibsPPC =        "{PPCLibraries}"InterfaceLib.xcoff ∂
  131.                         "{PPCLibraries}"MathLib.xcoff ∂
  132.                         "{PPCLibraries}"PPCCRuntime.o ∂
  133.                         "{PPCLibraries}"StdCLib.xcoff ∂
  134.                         "{PPCLibraries}"StdCRuntime.o
  135.                         
  136. # Define the library equates for the PowerPC.
  137. LIBEQUATES =             -l InterfaceLib.xcoff=InterfaceLib∂
  138.                         -l StdCLib.xcoff=StdCLib∂
  139.                         -l MathLib.xcoff=MathLib
  140.  
  141.                         
  142. # Define the libraries we must link with for the 68K. You may or may not need some of these.
  143. StandardLibs68K =         "{CLibraries}"CSANELib.o ∂
  144.                         "{CLibraries}"Math.o ∂
  145.                         "{CLibraries}"StdClib.o ∂
  146.                         "{Libraries}"Runtime.o ∂
  147.                         "{Libraries}"Interface.o        
  148.  
  149. # Define the various collections of object files. 
  150.  
  151. # Define the non-optimized PowerPC object files. You will need to fill in all of the correct
  152. # file names using the format "ObjectFile.c.o.noopt.PPC".
  153. PPCObjectsNoOpt =        "{PPCObjectsNoOptF}"MyObjectFile1.c.o.noopt.PPC    ∂
  154.                         "{PPCObjectsNoOptF}"MyObjectFile2.c.o.noopt.PPC
  155.  
  156. # Define the optimized PowerPC object files. You will need to fill in all of the correct
  157. # file names using the format "ObjectFile.c.o.opt.PPC"
  158. PPCObjectsOpt =         "{PPCObjectsOptF}"MyObjectFile1.c.o.opt.PPC ∂
  159.                         "{PPCObjectsOptF}"MyObjectFile2.c.o.opt.PPC
  160.  
  161. # Define the no optimized 68K object files. You will need to fill in all of the correct
  162. # file names using the format "ObjectFile.c.o.noopt.68K".
  163. 68KObjectsNoOpt =         "{68KObjectsNoOptF}"MyObjectFile1.c.o.noopt.68K ∂
  164.                         "{68KObjectsNoOptF}"MyObjectFile2.c.o.noopt.68K                        
  165.  
  166. # Define the optimized 68K object files. You will need to fill in all of the correct
  167. # file names using the format "ObjectFile.c.o.opt.68K".                    
  168. 68KObjectsOpt =            "{68KObjectsOptF}"MyObjectFile1.c.o.opt.68K ∂
  169.                         "{68KObjectsOptF}"MyObjectFile2.c.o.opt.68K
  170.                         
  171. # Make the objects folders (Non-optimized PowerPC, optimized PowerPC, non-optimized 68K, and 
  172. # optimized 68K) dependent on the sources folder.
  173. {PPCObjectsNoOptF}    ƒ {SourcesF}
  174. {PPCObjectsOptF}    ƒ {SourcesF}
  175. {68KObjectsNoOptF}    ƒ {SourcesF}
  176. {68KObjectsOptF}    ƒ {SourcesF}
  177.  
  178. # Make .c.o.noopt.PPC (non-optimized PowerPC C object files) files dependent on .c files.
  179. .c.o.noopt.PPC         ƒ .c
  180.     Echo "{default}.c — Starting to compile at "`Date`"."
  181.     PPCC -opt {PPCNoOptimizations} -i {IncludesF} -appleext on -w {SourcesF}{default}.c -o {PPCObjectsNoOptF}{default}.c.o.noopt.PPC
  182.     Echo "{default}.c — Through compiling at"`Date`"."
  183.     Echo " "
  184.  
  185. # Make .c.o.opt.PPC (optimized PowerPC C object files) files dependent on .c files.
  186. .c.o.opt.PPC         ƒ .c
  187.     Echo "{default}.c — Starting to compile at "`Date`"."
  188.     PPCC -opt {PPCOptimizations} -i {IncludesF} -appleext on -w {SourcesF}{default}.c -o {PPCObjectsOptF}{default}.c.o.opt.PPC
  189.     Echo "{default}.c - Through compiling at"`Date`"."
  190.     Echo " "
  191.  
  192. # Make .c.o.noopt.68K (non-optimized 68K C object files) files dependent on .c files.
  193. .c.o.noopt.68K         ƒ .c
  194.     Echo "{default}.c — Starting to compile at "`Date`"."
  195.     c -opt {68KNoOptimizations}  -i {IncludesF} {SourcesF}{default}.c -o {68KObjectsNoOptF}{default}.c.o.noopt.68k
  196.     Echo "{default}.c - Through compiling at"`Date`"."
  197.     Echo " "    
  198.  
  199. # Make .c.o.opt.68K (optimized 68K C object files) files dependent on .c files.
  200. .c.o.opt.68K         ƒ .c
  201.     Echo "{default}.c — Starting to compile at "`Date`"."
  202.     c -opt {68KOptimizations} -i {IncludesF} {SourcesF}{default}.c -o {68KObjectsOptF}{default}.c.o.opt.68k
  203.     Echo "{default}.c - Through compiling at"`Date`"."
  204.     Echo " "
  205.  
  206.  
  207. # Make the token all dependent on making the PowerPC non-optimized, PowerPC optimized, 68K
  208. # non-optimzied, 68K optimized, non-optimzed fat, and optimized fat versions of our
  209. # application.
  210. all    ƒ    {AppName}.noopt.PPC {AppName}.opt.PPC ∂
  211.         {AppName}.noopt.68K {AppName}.opt.68K ∂
  212.         {AppName}.noopt.fat {AppName}.opt.fat
  213.  
  214. # ----- PowerPC version of the application, non-optimized.
  215. {AppName}.noopt.PPC    ƒƒ {PPCObjectsNoOpt}
  216.     # Link 'em together
  217.     Echo "{TARG} — Starting to link at "`Date`"."
  218.     PPCLink {PPCObjectsNoOpt} {StandardLibsPPC} -sym {Symbolics} -o {TARG}.xcoff ∑ linker_messages
  219.     Echo "{TARG} — Through linking at "`Date`"."
  220.     
  221.     # Create pef executable
  222.     Echo "{TARG} — Starting to MakePEF at "`Date`"."
  223.     makepef {TARG}.xcoff -o {TARG} {LIBEQUATES}
  224.     Echo "{TARG} — Through doing MakePEF at "`Date`"."
  225.     
  226.     # Set the type and creator of the target.
  227.     Echo "{TARG} — Starting to set type and creator at "`Date`"."
  228.     setfile -t {Type} -c {Creator} -a Bi {TARG}
  229.     Echo "{TARG} — Through setting type and creator at "`Date`"."
  230.     
  231.     # Optional step for debugging
  232.     if {Symbolics}  =~ /on/
  233.         
  234.         Echo "{TARG} — Starting to MakeSym at "`Date`"."
  235.         makesym -r -o {TARG}.SYM    {TARG}.xcoff
  236.         Echo "{TARG} — Through doing MakeSym at "`Date`"."
  237.     end # If
  238.  
  239. {AppName}.noopt.PPC    ƒƒ {ResourcesF}{AppRscs} {ResourcesF}{PPCAppRscs}
  240.     Echo "{TARG} — Starting to Rez at "`Date`"."
  241.     rez {ResourcesF}{AppRscs} {ResourcesF}{PPCAppRscs} -a -o {TARG}
  242.     Echo "{TARG} — Through doing Rez at "`Date`"."
  243.  
  244. # ----- PowerPC version of the application, optimized.
  245. {AppName}.opt.PPC     ƒƒ {PPCObjectsOpt}
  246.     Echo "{TARG} — Starting to link at "`Date`"."
  247.     PPCLink {PPCObjectsOpt} {StandardLibsPPC} -sym {Symbolics} -o {TARG}.xcoff ∑ linker_messages
  248.     Echo "{TARG} — Through linking at "`Date`"."
  249.     
  250.     # Create the PEF executable
  251.     Echo "{TARG} — Starting to MakePEF at "`Date`"."
  252.     makepef {TARG}.xcoff -o {TARG} {LIBEQUATES}
  253.     Echo "{TARG} — Through doing MakePEF at "`Date`"."
  254.     
  255.     # Set the type and creator for the executable.
  256.     Echo "{TARG} — Starting to set type and creator at "`Date`"."
  257.     setfile -t {Type} -c {Creator} -a Bi {TARG}
  258.     Echo "{TARG} — Through setting type and creator at "`Date`"."
  259.  
  260. {AppName}.opt.PPC     ƒƒ {ResourcesF}{AppRscs} {ResourcesF}{PPCAppRscs}
  261.     Echo "{TARG} — Starting to Rez at "`Date`"."
  262.     rez {ResourcesF}{AppRscs} {ResourcesF}{PPCAppRscs} -a -o {TARG}
  263.     Echo "{TARG} — Through doing Rez at "`Date`"."
  264.     
  265. # ----- 680x0 version of the application, non-optimized.
  266. {AppName}.noopt.68K    ƒƒ {68kObjectsNoOpt}
  267.     # Link them together
  268.     Echo "{TARG} — Starting to link at "`Date`"."
  269.     Link {68kObjectsNoOpt} {StandardLibs68K} -o {TARG} 
  270.     Echo "{TARG} — Through linking at "`Date`"."
  271.     
  272.     # Set the type and creator of the target.
  273.     Echo "{TARG} — Starting to set type and creator at "`Date`"."
  274.     setfile -t {Type} -c {Creator} -a Bi {TARG}
  275.     Echo "{TARG} — Through setting type and creator at "`Date`"."
  276.  
  277. {AppName}.noopt.68K ƒƒ {ResourcesF}{AppRscs}
  278.     Echo "{TARG} — Starting to Rez at "`Date`"."
  279.     rez {ResourcesF}{AppRscs} -a -o {TARG}
  280.     Echo "{TARG} — Through doing Rez at "`Date`"."
  281.     
  282. # ----- 680x0 version of the application, optimized.
  283. {AppName}.opt.68K     ƒƒ {68KObjectsOpt}
  284.     # Link them together
  285.     Echo "{TARG} — Starting to link at "`Date`"."
  286.     Link {68KObjectsOpt} {StandardLibs68K} -o {TARG}
  287.     Echo "{TARG} — Through linking at "`Date`"."
  288.     
  289.     # Set the type and creator of the target.
  290.     Echo "{TARG} — Starting to set type and creator at "`Date`"."
  291.     setfile -t {Type} -c {Creator} -a Bi {TARG}
  292.     Echo "{TARG} — Through setting type and creator at "`Date`"."
  293.     
  294. {AppName}.opt.68K     ƒƒ {ResourcesF}{AppRscs}
  295.     Echo "{TARG} — Starting to Rez at "`Date`"."
  296.     rez {ResourcesF}{AppRscs} -a -o {TARG}
  297.     Echo "{TARG} — Through doing Rez at "`Date`"."
  298.  
  299. # ----- "Fat" Binary for 68K and PowerPC (68K and PowerPC version are non-optimized)
  300. {AppName}.noopt.fat    ƒƒ {AppName}.noopt.PPC {AppName}.noopt.68K {ResourcesF}{MergeCodeRscsNoOpt}
  301.     # Duplicate the PowerPC code into the fat binary package.
  302.     Echo "{TARG} — Starting to duplicate for fat binary at "`Date`"."
  303.     duplicate -y {AppName}.noopt.PPC {AppName}.noopt.fat
  304.     Echo "{TARG} — Through duplicating for fat binary at "`Date`"."
  305.     
  306.     # rez in 'CODE' resources from 68K version (68K name is in the .r file)
  307.     Echo "{TARG} — Starting to Rez for fat binary at "`Date`"."
  308.     rez {ResourcesF}{MergeCodeRscsNoOpt} -a -o {AppName}.noopt.fat
  309.     Echo "{TARG} — Through doing Rez at "`Date`"."
  310.  
  311. # ----- "Fat" Binary for 68K and PowerPC (68K and PowerPC versions are optimized)
  312. {AppName}.opt.fat     ƒƒ {AppName}.opt.PPC {AppName}.opt.68K {ResourcesF}{MergeCodeRscsOpt}
  313.     # Duplicate the PowerPC code into the fat binary package.
  314.     Echo "{TARG} — Starting to duplicate for fat binary at "`Date`"."
  315.     duplicate -y {AppName}.opt.PPC {AppName}.opt.fat
  316.     Echo "{TARG} — Through duplicating for fat binary at "`Date`"."
  317.     
  318.     # rez in 'CODE' resources from 68K version (68K name is in the .r file)
  319.     Echo "{TARG} — Starting to Rez for fat binary at "`Date`"."
  320.     rez {ResourcesF}{MergeCodeRscsOpt} -a -o {AppName}.opt.fat
  321.     Echo "{TARG} — Through doing Rez at "`Date`"."
  322.